import {
	post,
	get,
} from '@/api/request.js'

const buyvip = async (_this) => {
	const params = {
		vipid: _this.recoed.id
	}
	const res = await post('/v3/userinfo/buyvip', params)
	if (!res) return
	return res
}

const usersign = async () => {
	const res = await get('/v3/userinfo/usersign')
	if (!res) return
	return res
}

const getUserSession = async () => {
	const token = uni.getStorageSync('token')
	const params = {
		"User-Token": token
	}
	const res = await post('/v3/login/userSession', params)
	if (!res) return
	if (res.data.code == 200) {
		// const login = 'ok'
		// const userInfo = {
		// 	id: res.data.data.id,
		// 	userName: res.data.data.username,
		// 	userAvatar: res.data.data.useravatar,
		// 	userCion: res.data.data.usercion,
		// 	signDaily: res.data.data.signdaily
		// }
		// uni.setStorageSync('login', login)
		// uni.setStorageSync('userInfo', userInfo)
		return res
	} else {
		// const login = 'no'
		// uni.setStorageSync('login', login)
		// uni.removeStorageSync('userInfo')
		// uni.removeStorageSync('UserToken')
		return
	}
}

const getRankListData = async () => {
	const res = await get('/v3/weli/timesign/limit/20')
	if (!res) return
	return res
}

module.exports = {
	buyvip,
	usersign,
	getUserSession,
	getRankListData,
}